package com.afinal.intelligencetrash.Model.bean;

import java.text.SimpleDateFormat;

/**
 * Created by 厂里帅小伙 on 2/21 0021.
 */

public class Message implements Comparable{

    //    只有private修饰的字段才会被映射到数据库表中，即如果有某一个字段不想映射的话，就设置为public、protected或者default修饰符就可以了。
    private int messageId;
    private long time;
    private String content;

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public Message(String content, long time) {
        this.content = content;
        this.time = time;
    }

    public String getLocalTime(){
        SimpleDateFormat timeformat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
        return timeformat.format(time);
    }

    public int getMessageId() {
        return messageId;
    }

    public void setMessageId(int messageId) {
        this.messageId = messageId;
    }

    @Override
    public int compareTo(Object o) {
        Message oo = (Message) o;
        return (int)(this.time - oo.getTime());
    }
}
